home *** CD-ROM | disk | FTP | other *** search
- Subject: v24i017: GNU Diff, version 1.15, Part02/08
- Newsgroups: comp.sources.unix
- Approved: rsalz@uunet.UU.NET
- X-Checksum-Snefru: 0ddde865 39dd146b cb649012 1dd9e34f
-
- Submitted-by: Paul Eggert <eggert@twinsun.com>
- Posting-number: Volume 24, Issue 17
- Archive-name: gnudiff1.15/part02
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 2 (of 8)."
- # Contents: COPYING context.c diff.h regex.h
- # Wrapped by eggert@ata on Mon Jan 7 11:25:28 1991
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'COPYING' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'COPYING'\"
- else
- echo shar: Extracting \"'COPYING'\" \(12488 characters\)
- sed "s/^X//" >'COPYING' <<'END_OF_FILE'
- X
- X GNU GENERAL PUBLIC LICENSE
- X Version 1, February 1989
- X
- X Copyright (C) 1989 Free Software Foundation, Inc.
- X 675 Mass Ave, Cambridge, MA 02139, USA
- X Everyone is permitted to copy and distribute verbatim copies
- X of this license document, but changing it is not allowed.
- X
- X Preamble
- X
- X The license agreements of most software companies try to keep users
- Xat the mercy of those companies. By contrast, our General Public
- XLicense is intended to guarantee your freedom to share and change free
- Xsoftware--to make sure the software is free for all its users. The
- XGeneral Public License applies to the Free Software Foundation's
- Xsoftware and to any other program whose authors commit to using it.
- XYou can use it for your programs, too.
- X
- X When we speak of free software, we are referring to freedom, not
- Xprice. Specifically, the General Public License is designed to make
- Xsure that you have the freedom to give away or sell copies of free
- Xsoftware, that you receive source code or can get it if you want it,
- Xthat you can change the software or use pieces of it in new free
- Xprograms; and that you know you can do these things.
- X
- X To protect your rights, we need to make restrictions that forbid
- Xanyone to deny you these rights or to ask you to surrender the rights.
- XThese restrictions translate to certain responsibilities for you if you
- Xdistribute copies of the software, or if you modify it.
- X
- X For example, if you distribute copies of a such a program, whether
- Xgratis or for a fee, you must give the recipients all the rights that
- Xyou have. You must make sure that they, too, receive or can get the
- Xsource code. And you must tell them their rights.
- X
- X We protect your rights with two steps: (1) copyright the software, and
- X(2) offer you this license which gives you legal permission to copy,
- Xdistribute and/or modify the software.
- X
- X Also, for each author's protection and ours, we want to make certain
- Xthat everyone understands that there is no warranty for this free
- Xsoftware. If the software is modified by someone else and passed on, we
- Xwant its recipients to know that what they have is not the original, so
- Xthat any problems introduced by others will not reflect on the original
- Xauthors' reputations.
- X
- X The precise terms and conditions for copying, distribution and
- Xmodification follow.
- X
- X GNU GENERAL PUBLIC LICENSE
- X TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
- X
- X 0. This License Agreement applies to any program or other work which
- Xcontains a notice placed by the copyright holder saying it may be
- Xdistributed under the terms of this General Public License. The
- X"Program", below, refers to any such program or work, and a "work based
- Xon the Program" means either the Program or any work containing the
- XProgram or a portion of it, either verbatim or with modifications. Each
- Xlicensee is addressed as "you".
- X
- X 1. You may copy and distribute verbatim copies of the Program's source
- Xcode as you receive it, in any medium, provided that you conspicuously and
- Xappropriately publish on each copy an appropriate copyright notice and
- Xdisclaimer of warranty; keep intact all the notices that refer to this
- XGeneral Public License and to the absence of any warranty; and give any
- Xother recipients of the Program a copy of this General Public License
- Xalong with the Program. You may charge a fee for the physical act of
- Xtransferring a copy.
- X
- X 2. You may modify your copy or copies of the Program or any portion of
- Xit, and copy and distribute such modifications under the terms of Paragraph
- X1 above, provided that you also do the following:
- X
- X a) cause the modified files to carry prominent notices stating that
- X you changed the files and the date of any change; and
- X
- X b) cause the whole of any work that you distribute or publish, that
- X in whole or in part contains the Program or any part thereof, either
- X with or without modifications, to be licensed at no charge to all
- X third parties under the terms of this General Public License (except
- X that you may choose to grant warranty protection to some or all
- X third parties, at your option).
- X
- X c) If the modified program normally reads commands interactively when
- X run, you must cause it, when started running for such interactive use
- X in the simplest and most usual way, to print or display an
- X announcement including an appropriate copyright notice and a notice
- X that there is no warranty (or else, saying that you provide a
- X warranty) and that users may redistribute the program under these
- X conditions, and telling the user how to view a copy of this General
- X Public License.
- X
- X d) You may charge a fee for the physical act of transferring a
- X copy, and you may at your option offer warranty protection in
- X exchange for a fee.
- X
- XMere aggregation of another independent work with the Program (or its
- Xderivative) on a volume of a storage or distribution medium does not bring
- Xthe other work under the scope of these terms.
- X
- X 3. You may copy and distribute the Program (or a portion or derivative of
- Xit, under Paragraph 2) in object code or executable form under the terms of
- XParagraphs 1 and 2 above provided that you also do one of the following:
- X
- X a) accompany it with the complete corresponding machine-readable
- X source code, which must be distributed under the terms of
- X Paragraphs 1 and 2 above; or,
- X
- X b) accompany it with a written offer, valid for at least three
- X years, to give any third party free (except for a nominal charge
- X for the cost of distribution) a complete machine-readable copy of the
- X corresponding source code, to be distributed under the terms of
- X Paragraphs 1 and 2 above; or,
- X
- X c) accompany it with the information you received as to where the
- X corresponding source code may be obtained. (This alternative is
- X allowed only for noncommercial distribution and only if you
- X received the program in object code or executable form alone.)
- X
- XSource code for a work means the preferred form of the work for making
- Xmodifications to it. For an executable file, complete source code means
- Xall the source code for all modules it contains; but, as a special
- Xexception, it need not include source code for modules which are standard
- Xlibraries that accompany the operating system on which the executable
- Xfile runs, or for standard header files or definitions files that
- Xaccompany that operating system.
- X
- X 4. You may not copy, modify, sublicense, distribute or transfer the
- XProgram except as expressly provided under this General Public License.
- XAny attempt otherwise to copy, modify, sublicense, distribute or transfer
- Xthe Program is void, and will automatically terminate your rights to use
- Xthe Program under this License. However, parties who have received
- Xcopies, or rights to use copies, from you under this General Public
- XLicense will not have their licenses terminated so long as such parties
- Xremain in full compliance.
- X
- X 5. By copying, distributing or modifying the Program (or any work based
- Xon the Program) you indicate your acceptance of this license to do so,
- Xand all its terms and conditions.
- X
- X 6. Each time you redistribute the Program (or any work based on the
- XProgram), the recipient automatically receives a license from the original
- Xlicensor to copy, distribute or modify the Program subject to these
- Xterms and conditions. You may not impose any further restrictions on the
- Xrecipients' exercise of the rights granted herein.
- X
- X 7. The Free Software Foundation may publish revised and/or new versions
- Xof the General Public License from time to time. Such new versions will
- Xbe similar in spirit to the present version, but may differ in detail to
- Xaddress new problems or concerns.
- X
- XEach version is given a distinguishing version number. If the Program
- Xspecifies a version number of the license which applies to it and "any
- Xlater version", you have the option of following the terms and conditions
- Xeither of that version or of any later version published by the Free
- XSoftware Foundation. If the Program does not specify a version number of
- Xthe license, you may choose any version ever published by the Free Software
- XFoundation.
- X
- X 8. If you wish to incorporate parts of the Program into other free
- Xprograms whose distribution conditions are different, write to the author
- Xto ask for permission. For software which is copyrighted by the Free
- XSoftware Foundation, write to the Free Software Foundation; we sometimes
- Xmake exceptions for this. Our decision will be guided by the two goals
- Xof preserving the free status of all derivatives of our free software and
- Xof promoting the sharing and reuse of software generally.
- X
- X NO WARRANTY
- X
- X 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
- XFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
- XOTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
- XPROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
- XOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- XMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
- XTO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
- XPROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
- XREPAIR OR CORRECTION.
- X
- X 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
- XWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
- XREDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
- XINCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
- XOUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
- XTO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
- XYOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
- XPROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
- XPOSSIBILITY OF SUCH DAMAGES.
- X
- X END OF TERMS AND CONDITIONS
- X
- X Appendix: How to Apply These Terms to Your New Programs
- X
- X If you develop a new program, and you want it to be of the greatest
- Xpossible use to humanity, the best way to achieve this is to make it
- Xfree software which everyone can redistribute and change under these
- Xterms.
- X
- X To do so, attach the following notices to the program. It is safest to
- Xattach them to the start of each source file to most effectively convey
- Xthe exclusion of warranty; and each file should have at least the
- X"copyright" line and a pointer to where the full notice is found.
- X
- X <one line to give the program's name and a brief idea of what it does.>
- X Copyright (C) 19yy <name of author>
- X
- X This program is free software; you can redistribute it and/or modify
- X it under the terms of the GNU General Public License as published by
- X the Free Software Foundation; either version 1, or (at your option)
- X any later version.
- X
- X This program is distributed in the hope that it will be useful,
- X but WITHOUT ANY WARRANTY; without even the implied warranty of
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X GNU General Public License for more details.
- X
- X You should have received a copy of the GNU General Public License
- X along with this program; if not, write to the Free Software
- X Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X
- XAlso add information on how to contact you by electronic and paper mail.
- X
- XIf the program is interactive, make it output a short notice like this
- Xwhen it starts in an interactive mode:
- X
- X Gnomovision version 69, Copyright (C) 19xx name of author
- X Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- X This is free software, and you are welcome to redistribute it
- X under certain conditions; type `show c' for details.
- X
- XThe hypothetical commands `show w' and `show c' should show the
- Xappropriate parts of the General Public License. Of course, the
- Xcommands you use may be called something other than `show w' and `show
- Xc'; they could even be mouse-clicks or menu items--whatever suits your
- Xprogram.
- X
- XYou should also get your employer (if you work as a programmer) or your
- Xschool, if any, to sign a "copyright disclaimer" for the program, if
- Xnecessary. Here a sample; alter the names:
- X
- X Yoyodyne, Inc., hereby disclaims all copyright interest in the
- X program `Gnomovision' (a program to direct compilers to make passes
- X at assemblers) written by James Hacker.
- X
- X <signature of Ty Coon>, 1 April 1989
- X Ty Coon, President of Vice
- X
- XThat's all there is to it!
- END_OF_FILE
- if test 12488 -ne `wc -c <'COPYING'`; then
- echo shar: \"'COPYING'\" unpacked with wrong size!
- fi
- # end of 'COPYING'
- fi
- if test -f 'context.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'context.c'\"
- else
- echo shar: Extracting \"'context.c'\" \(12479 characters\)
- sed "s/^X//" >'context.c' <<'END_OF_FILE'
- X/* Context-format output routines for GNU DIFF.
- X Copyright (C) 1988, 1989 Free Software Foundation, Inc.
- X
- XThis file is part of GNU DIFF.
- X
- XGNU DIFF is free software; you can redistribute it and/or modify
- Xit under the terms of the GNU General Public License as published by
- Xthe Free Software Foundation; either version 1, or (at your option)
- Xany later version.
- X
- XGNU DIFF is distributed in the hope that it will be useful,
- Xbut WITHOUT ANY WARRANTY; without even the implied warranty of
- XMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- XGNU General Public License for more details.
- X
- XYou should have received a copy of the GNU General Public License
- Xalong with GNU DIFF; see the file COPYING. If not, write to
- Xthe Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
- X
- X#include "diff.h"
- X#include "regex.h"
- X
- Xstatic void pr_context_hunk ();
- Xstatic void pr_unidiff_hunk ();
- Xstatic struct change *find_hunk ();
- Xstatic void mark_ignorable ();
- Xstatic void find_function ();
- X
- X/* Last place find_function started searching from. */
- Xstatic int find_function_last_search;
- X
- X/* The value find_function returned when it started searching there. */
- Xstatic int find_function_last_match;
- X
- X/* Print a label for a context diff, with a file name and date or a label. */
- X
- Xstatic void
- Xprint_context_label (mark, inf, label)
- X const char *mark;
- X struct file_data *inf;
- X const char *label;
- X{
- X if (label)
- X fprintf (outfile, "%s %s\n", mark, label);
- X else if (inf->stat.st_mtime)
- X fprintf (outfile, "%s %s\t%s", mark, inf->name, ctime(&inf->stat.st_mtime));
- X else
- X /* Don't pretend that standard input is ancient. */
- X fprintf (outfile, "%s %s\n", mark, inf->name);
- X}
- X
- X/* Print a header for a context diff, with the file names and dates. */
- X
- Xvoid
- Xprint_context_header (inf, unidiff_flag)
- X struct file_data *inf;
- X int unidiff_flag;
- X{
- X if (unidiff_flag)
- X {
- X print_context_label ("---", &inf[0], file_label[0]);
- X print_context_label ("+++", &inf[1], file_label[1]);
- X }
- X else
- X {
- X print_context_label ("***", &inf[0], file_label[0]);
- X print_context_label ("---", &inf[1], file_label[1]);
- X }
- X}
- X
- X/* Print an edit script in context format. */
- X
- Xvoid
- Xprint_context_script (script, unidiff_flag)
- X struct change *script;
- X int unidiff_flag;
- X{
- X if (ignore_blank_lines_flag || ignore_regexp)
- X mark_ignorable (script);
- X else
- X {
- X struct change *e;
- X for (e = script; e; e = e->link)
- X e->ignore = 0;
- X }
- X
- X find_function_last_search = 0;
- X find_function_last_match = -1;
- X
- X if (unidiff_flag)
- X print_script (script, find_hunk, pr_unidiff_hunk);
- X else
- X print_script (script, find_hunk, pr_context_hunk);
- X}
- X
- X/* Print a pair of line numbers with a comma, translated for file FILE.
- X If the second number is not greater, use the first in place of it.
- X
- X Args A and B are internal line numbers.
- X We print the translated (real) line numbers. */
- X
- Xstatic void
- Xprint_context_number_range (file, a, b)
- X struct file_data *file;
- X int a, b;
- X{
- X int trans_a, trans_b;
- X translate_range (file, a, b, &trans_a, &trans_b);
- X
- X /* Note: we can have B < A in the case of a range of no lines.
- X In this case, we should print the line number before the range,
- X which is B. */
- X if (trans_b > trans_a)
- X fprintf (outfile, "%d,%d", trans_a, trans_b);
- X else
- X fprintf (outfile, "%d", trans_b);
- X}
- X
- X/* Print a portion of an edit script in context format.
- X HUNK is the beginning of the portion to be printed.
- X The end is marked by a `link' that has been nulled out.
- X
- X Prints out lines from both files, and precedes each
- X line with the appropriate flag-character. */
- X
- Xstatic void
- Xpr_context_hunk (hunk)
- X struct change *hunk;
- X{
- X int first0, last0, first1, last1, show_from, show_to, i;
- X struct change *next;
- X char *prefix;
- X char *function;
- X int function_length;
- X
- X /* Determine range of line numbers involved in each file. */
- X
- X analyze_hunk (hunk, &first0, &last0, &first1, &last1, &show_from, &show_to);
- X
- X if (!show_from && !show_to)
- X return;
- X
- X /* Include a context's width before and after. */
- X
- X first0 = max (first0 - context, 0);
- X first1 = max (first1 - context, 0);
- X last0 = min (last0 + context, files[0].buffered_lines - 1);
- X last1 = min (last1 + context, files[1].buffered_lines - 1);
- X
- X /* If desired, find the preceding function definition line in file 0. */
- X function = 0;
- X if (function_regexp)
- X find_function (&files[0], first0, &function, &function_length);
- X
- X /* If we looked for and found a function this is part of,
- X include its name in the header of the diff section. */
- X fprintf (outfile, "***************");
- X
- X if (function)
- X {
- X fprintf (outfile, " ");
- X fwrite (function, 1, min (function_length - 1, 40), outfile);
- X }
- X
- X fprintf (outfile, "\n*** ");
- X print_context_number_range (&files[0], first0, last0);
- X fprintf (outfile, " ****\n");
- X
- X if (show_from)
- X {
- X next = hunk;
- X
- X for (i = first0; i <= last0; i++)
- X {
- X /* Skip past changes that apply (in file 0)
- X only to lines before line I. */
- X
- X while (next && next->line0 + next->deleted <= i)
- X next = next->link;
- X
- X /* Compute the marking for line I. */
- X
- X prefix = " ";
- X if (next && next->line0 <= i)
- X /* The change NEXT covers this line.
- X If lines were inserted here in file 1, this is "changed".
- X Otherwise it is "deleted". */
- X prefix = (next->inserted > 0 ? "!" : "-");
- X
- X print_1_line (prefix, &files[0].linbuf[i]);
- X }
- X }
- X
- X fprintf (outfile, "--- ");
- X print_context_number_range (&files[1], first1, last1);
- X fprintf (outfile, " ----\n");
- X
- X if (show_to)
- X {
- X next = hunk;
- X
- X for (i = first1; i <= last1; i++)
- X {
- X /* Skip past changes that apply (in file 1)
- X only to lines before line I. */
- X
- X while (next && next->line1 + next->inserted <= i)
- X next = next->link;
- X
- X /* Compute the marking for line I. */
- X
- X prefix = " ";
- X if (next && next->line1 <= i)
- X /* The change NEXT covers this line.
- X If lines were deleted here in file 0, this is "changed".
- X Otherwise it is "inserted". */
- X prefix = (next->deleted > 0 ? "!" : "+");
- X
- X print_1_line (prefix, &files[1].linbuf[i]);
- X }
- X }
- X}
- X
- X/* Print a pair of line numbers with a comma, translated for file FILE.
- X If the second number is smaller, use the first in place of it.
- X If the numbers are equal, print just one number.
- X
- X Args A and B are internal line numbers.
- X We print the translated (real) line numbers. */
- X
- Xstatic void
- Xprint_unidiff_number_range (file, a, b)
- X struct file_data *file;
- X int a, b;
- X{
- X int trans_a, trans_b;
- X translate_range (file, a, b, &trans_a, &trans_b);
- X
- X /* Note: we can have B < A in the case of a range of no lines.
- X In this case, we should print the line number before the range,
- X which is B. */
- X if (trans_b <= trans_a)
- X fprintf (outfile, trans_b == trans_a ? "%d" : "%d,0", trans_b);
- X else
- X fprintf (outfile, "%d,%d", trans_a, trans_b - trans_a + 1);
- X}
- X
- X/* Print a portion of an edit script in unidiff format.
- X HUNK is the beginning of the portion to be printed.
- X The end is marked by a `link' that has been nulled out.
- X
- X Prints out lines from both files, and precedes each
- X line with the appropriate flag-character. */
- X
- Xstatic void
- Xpr_unidiff_hunk (hunk)
- X struct change *hunk;
- X{
- X int first0, last0, first1, last1, show_from, show_to, i, j, k;
- X struct change *next;
- X int lastline;
- X char *function;
- X int function_length;
- X
- X /* Determine range of line numbers involved in each file. */
- X
- X analyze_hunk (hunk, &first0, &last0, &first1, &last1, &show_from, &show_to);
- X
- X if (!show_from && !show_to)
- X return;
- X
- X /* Include a context's width before and after. */
- X
- X first0 = max (first0 - context, 0);
- X first1 = max (first1 - context, 0);
- X last0 = min (last0 + context, files[0].buffered_lines - 1);
- X last1 = min (last1 + context, files[1].buffered_lines - 1);
- X
- X /* If desired, find the preceding function definition line in file 0. */
- X function = 0;
- X if (function_regexp)
- X find_function (&files[0], first0, &function, &function_length);
- X
- X /* If we looked for and found a function this is part of,
- X include its name in the header of the diff section. */
- X
- X fprintf (outfile, "@@ -");
- X print_unidiff_number_range (&files[0], first0, last0);
- X fprintf (outfile, " +");
- X print_unidiff_number_range (&files[1], first1, last1);
- X fprintf (outfile, " @@");
- X
- X if (function)
- X {
- X putc (' ', outfile);
- X fwrite (function, 1, min (function_length - 1, 40), outfile);
- X }
- X putc ('\n', outfile);
- X
- X next = hunk;
- X i = first0;
- X j = first1;
- X
- X while (i <= last0 || j <= last1)
- X {
- X
- X /* If the line isn't a difference, output the context from file 0. */
- X
- X if (!next || i < next->line0)
- X {
- X putc (' ', outfile);
- X print_1_line ((char *)0, &files[0].linbuf[i++]);
- X j++;
- X }
- X else
- X {
- X /* For each difference, first output the deleted part. */
- X
- X k = next->deleted;
- X while (k--)
- X {
- X putc ('-', outfile);
- X print_1_line ((char *)0, &files[0].linbuf[i++]);
- X }
- X
- X /* Then output the inserted part. */
- X
- X k = next->inserted;
- X while (k--)
- X {
- X putc ('+', outfile);
- X print_1_line ((char *)0, &files[1].linbuf[j++]);
- X }
- X
- X /* We're done with this hunk, so on to the next! */
- X
- X next = next->link;
- X }
- X }
- X}
- X
- X/* Scan a (forward-ordered) edit script for the first place that at least
- X 2*CONTEXT unchanged lines appear, and return a pointer
- X to the `struct change' for the last change before those lines. */
- X
- Xstatic struct change *
- Xfind_hunk (start)
- X struct change *start;
- X{
- X struct change *prev;
- X int top0, top1;
- X int thresh;
- X
- X do
- X {
- X /* Computer number of first line in each file beyond this changed. */
- X top0 = start->line0 + start->deleted;
- X top1 = start->line1 + start->inserted;
- X prev = start;
- X start = start->link;
- X /* Threshold distance is 2*CONTEXT between two non-ignorable changes,
- X but only CONTEXT if one is ignorable. */
- X thresh = ((prev->ignore || (start && start->ignore))
- X ? context
- X : 2 * context);
- X /* It is not supposed to matter which file we check in the end-test.
- X If it would matter, crash. */
- X if (start && start->line0 - top0 != start->line1 - top1)
- X abort ();
- X } while (start
- X /* Keep going if less than THRESH lines
- X elapse before the affected line. */
- X && start->line0 < top0 + thresh);
- X
- X return prev;
- X}
- X
- X/* Set the `ignore' flag properly in each change in SCRIPT.
- X It should be 1 if all the lines inserted or deleted in that change
- X are ignorable lines. */
- X
- Xstatic void
- Xmark_ignorable (script)
- X struct change *script;
- X{
- X while (script)
- X {
- X struct change *next = script->link;
- X int first0, last0, first1, last1, deletes, inserts;
- X
- X /* Turn this change into a hunk: detach it from the others. */
- X script->link = 0;
- X
- X /* Determine whether this change is ignorable. */
- X analyze_hunk (script, &first0, &last0, &first1, &last1, &deletes, &inserts);
- X /* Reconnect the chain as before. */
- X script->link = next;
- X
- X /* If the change is ignorable, mark it. */
- X script->ignore = (!deletes && !inserts);
- X
- X /* Advance to the following change. */
- X script = next;
- X }
- X}
- X
- X/* Find the last function-header line in FILE prior to line number LINENUM.
- X This is a line containing a match for the regexp in `function_regexp'.
- X Store the address of the line text into LINEP and the length of the
- X line into LENP.
- X Do not store anything if no function-header is found. */
- X
- Xstatic void
- Xfind_function (file, linenum, linep, lenp)
- X struct file_data *file;
- X int linenum;
- X char **linep;
- X int *lenp;
- X{
- X int i = linenum;
- X int last = find_function_last_search;
- X find_function_last_search = i;
- X
- X while (--i >= last)
- X {
- X /* See if this line is what we want. */
- X
- X if (0 <= re_search (&function_regexp_compiled,
- X file->linbuf[i].text,
- X file->linbuf[i].length,
- X 0, file->linbuf[i].length,
- X 0))
- X {
- X *linep = file->linbuf[i].text;
- X *lenp = file->linbuf[i].length;
- X find_function_last_match = i;
- X return;
- X }
- X }
- X /* If we search back to where we started searching the previous time,
- X find the line we found last time. */
- X if (find_function_last_match >= 0)
- X {
- X i = find_function_last_match;
- X *linep = file->linbuf[i].text;
- X *lenp = file->linbuf[i].length;
- X return;
- X }
- X return;
- X}
- END_OF_FILE
- if test 12479 -ne `wc -c <'context.c'`; then
- echo shar: \"'context.c'\" unpacked with wrong size!
- fi
- # end of 'context.c'
- fi
- if test -f 'diff.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'diff.h'\"
- else
- echo shar: Extracting \"'diff.h'\" \(10400 characters\)
- sed "s/^X//" >'diff.h' <<'END_OF_FILE'
- X/* Shared definitions for GNU DIFF
- X Copyright (C) 1988, 1989 Free Software Foundation, Inc.
- X
- XThis file is part of GNU DIFF.
- X
- XGNU DIFF is free software; you can redistribute it and/or modify
- Xit under the terms of the GNU General Public License as published by
- Xthe Free Software Foundation; either version 1, or (at your option)
- Xany later version.
- X
- XGNU DIFF is distributed in the hope that it will be useful,
- Xbut WITHOUT ANY WARRANTY; without even the implied warranty of
- XMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- XGNU General Public License for more details.
- X
- XYou should have received a copy of the GNU General Public License
- Xalong with GNU DIFF; see the file COPYING. If not, write to
- Xthe Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
- X
- X
- X#include <ctype.h>
- X#include <stdio.h>
- X#include <sys/types.h>
- X#include <sys/stat.h>
- X
- X#ifdef USG
- X#include <time.h>
- X#ifdef HAVE_NDIR
- X#ifdef NDIR_IN_SYS
- X#include <sys/ndir.h>
- X#else
- X#include <ndir.h>
- X#endif /* not NDIR_IN_SYS */
- X#else
- X#include <dirent.h>
- X#endif /* not HAVE_NDIR */
- X#include <fcntl.h>
- X#ifndef HAVE_DIRECT
- X#define direct dirent
- X#endif
- X#else /* not USG */
- X#include <sys/time.h>
- X#include <sys/dir.h>
- X#include <sys/file.h>
- X#endif
- X
- X#ifdef USG
- X/* Define needed BSD functions in terms of sysV library. */
- X
- X#define bcopy(s,d,n) memcpy((d),(s),(n))
- X#define bcmp(s1,s2,n) memcmp((s1),(s2),(n))
- X#define bzero(s,n) memset((s),0,(n))
- X
- X#ifndef XENIX
- X#define dup2(f,t) (close(t),fcntl((f),F_DUPFD,(t)))
- X#endif
- X
- X#define vfork fork
- X#define index strchr
- X#define rindex strrchr
- X#endif
- X
- X#ifdef sparc
- X/* vfork clobbers registers on the Sparc, so don't use it. */
- X#define vfork fork
- X#endif
- X
- X#include <errno.h>
- Xextern int errno;
- Xextern int sys_nerr;
- Xextern char *sys_errlist[];
- X
- X#define EOS (0)
- X#define FALSE (0)
- X#define TRUE 1
- X
- X#define min(a,b) ((a) <= (b) ? (a) : (b))
- X#define max(a,b) ((a) >= (b) ? (a) : (b))
- X
- X#ifndef PR_FILE_NAME
- X#define PR_FILE_NAME "/bin/pr"
- X#endif
- X
- X/* Support old-fashioned C compilers. */
- X#if defined (__STDC__) || defined (__GNUC__)
- X#include "limits.h"
- X#else
- X#define INT_MAX 2147483647
- X#define CHAR_BIT 8
- X#endif
- X
- X/* Support old-fashioned C compilers. */
- X#if !defined (__STDC__) && !defined (__GNUC__)
- X#define const
- X#endif
- X
- X#ifndef O_RDONLY
- X#define O_RDONLY 0
- X#endif
- X
- X/* Variables for command line options */
- X
- X#ifndef GDIFF_MAIN
- X#define EXTERN extern
- X#else
- X#define EXTERN
- X#endif
- X
- Xenum output_style {
- X /* Default output style. */
- X OUTPUT_NORMAL,
- X /* Output the differences with lines of context before and after (-c). */
- X OUTPUT_CONTEXT,
- X /* Output the differences in a unified context diff format (-u). */
- X OUTPUT_UNIFIED,
- X /* Output the differences as commands suitable for `ed' (-e). */
- X OUTPUT_ED,
- X /* Output the diff as a forward ed script (-f). */
- X OUTPUT_FORWARD_ED,
- X /* Like -f, but output a count of changed lines in each "command" (-n). */
- X OUTPUT_RCS,
- X /* Output merged #ifdef'd file (-D). */
- X OUTPUT_IFDEF };
- X
- X/* True for output styles that are robust,
- X i.e. can handle a file that ends in a non-newline. */
- X#define ROBUST_OUTPUT_STYLE(S) \
- X ((S) == OUTPUT_CONTEXT || (S) == OUTPUT_UNIFIED || (S) == OUTPUT_RCS \
- X || (S) == OUTPUT_NORMAL)
- X
- XEXTERN enum output_style output_style;
- X
- X/* Number of lines of context to show in each set of diffs.
- X This is zero when context is not to be shown. */
- XEXTERN int context;
- X
- X/* Consider all files as text files (-a).
- X Don't interpret codes over 0177 as implying a "binary file". */
- XEXTERN int always_text_flag;
- X
- X/* Ignore changes in horizontal whitespace (-b). */
- XEXTERN int ignore_space_change_flag;
- X
- X/* Ignore all horizontal whitespace (-w). */
- XEXTERN int ignore_all_space_flag;
- X
- X/* Ignore changes that affect only blank lines (-B). */
- XEXTERN int ignore_blank_lines_flag;
- X
- X/* Ignore changes that affect only lines matching this regexp (-I). */
- XEXTERN char *ignore_regexp;
- X
- X/* Result of regex-compilation of `ignore_regexp'. */
- XEXTERN struct re_pattern_buffer ignore_regexp_compiled;
- X
- X/* 1 if lines may match even if their lengths are different.
- X This depends on various options. */
- XEXTERN int length_varies;
- X
- X/* Ignore differences in case of letters (-i). */
- XEXTERN int ignore_case_flag;
- X
- X/* File labels for `-c' output headers (-L). */
- XEXTERN char *file_label[2];
- X
- X/* Regexp to identify function-header lines (-F). */
- XEXTERN char *function_regexp;
- X
- X/* Result of regex-compilation of `function_regexp'. */
- XEXTERN struct re_pattern_buffer function_regexp_compiled;
- X
- X/* Say only whether files differ, not how (-q). */
- XEXTERN int no_details_flag;
- X
- X/* Report files compared that match (-s).
- X Normally nothing is output when that happens. */
- XEXTERN int print_file_same_flag;
- X
- X/* character that ends a line. Currently this is always `\n'. */
- XEXTERN char line_end_char;
- X
- X/* Output the differences with exactly 8 columns added to each line
- X so that any tabs in the text line up properly (-T). */
- XEXTERN int tab_align_flag;
- X
- X/* Expand tabs in the output so the text lines up properly
- X despite the characters added to the front of each line (-t). */
- XEXTERN int tab_expand_flag;
- X
- X/* In directory comparison, specify file to start with (-S).
- X All file names less than this name are ignored. */
- XEXTERN char *dir_start_file;
- X
- X/* If a file is new (appears in only one dir)
- X include its entire contents (-N).
- X Then `patch' would create the file with appropriate contents. */
- XEXTERN int entire_new_file_flag;
- X
- X/* Pipe each file's output through pr (-l). */
- XEXTERN int paginate_flag;
- X
- X/* String to use for #ifdef (-D). */
- XEXTERN char * ifdef_string;
- X
- X/* String containing all the command options diff received,
- X with spaces between and at the beginning but none at the end.
- X If there were no options given, this string is empty. */
- XEXTERN char * switch_string;
- X
- X/* Nonzero means use heuristics for better speed. */
- XEXTERN int heuristic;
- X
- X/* Name of program the user invoked (for error messages). */
- XEXTERN char * program;
- X
- X/* The result of comparison is an "edit script": a chain of `struct change'.
- X Each `struct change' represents one place where some lines are deleted
- X and some are inserted.
- X
- X LINE0 and LINE1 are the first affected lines in the two files (origin 0).
- X DELETED is the number of lines deleted here from file 0.
- X INSERTED is the number of lines inserted here in file 1.
- X
- X If DELETED is 0 then LINE0 is the number of the line before
- X which the insertion was done; vice versa for INSERTED and LINE1. */
- X
- Xstruct change
- X{
- X struct change *link; /* Previous or next edit command */
- X int inserted; /* # lines of file 1 changed here. */
- X int deleted; /* # lines of file 0 changed here. */
- X int line0; /* Line number of 1st deleted line. */
- X int line1; /* Line number of 1st inserted line. */
- X char ignore; /* Flag used in context.c */
- X};
- X
- X/* Structures that describe the input files. */
- X
- X/* Data on one line of text. */
- X
- Xstruct line_def {
- X char *text;
- X int length;
- X unsigned hash;
- X};
- X
- X/* Data on one input file being compared. */
- X
- Xstruct file_data {
- X int desc; /* File descriptor */
- X char *name; /* File name */
- X struct stat stat; /* File status from fstat() */
- X int dir_p; /* 1 if file is a directory */
- X
- X /* Buffer in which text of file is read. */
- X char * buffer;
- X /* Allocated size of buffer. */
- X int bufsize;
- X /* Number of valid characters now in the buffer. */
- X int buffered_chars;
- X
- X /* Array of data on analyzed lines of this chunk of this file. */
- X struct line_def *linbuf;
- X
- X /* Allocated size of linbuf array (# of elements). */
- X int linbufsize;
- X
- X /* Number of elements of linbuf containing valid data. */
- X int buffered_lines;
- X
- X /* Pointer to end of prefix of this file to ignore when hashing. */
- X char *prefix_end;
- X
- X /* Count of lines in the prefix. */
- X int prefix_lines;
- X
- X /* Pointer to start of suffix of this file to ignore when hashing. */
- X char *suffix_begin;
- X
- X /* Count of lines in the suffix. */
- X int suffix_lines;
- X
- X /* Vector, indexed by line number, containing an equivalence code for
- X each line. It is this vector that is actually compared with that
- X of another file to generate differences. */
- X int *equivs;
- X
- X /* Vector, like the previous one except that
- X the elements for discarded lines have been squeezed out. */
- X int *undiscarded;
- X
- X /* Vector mapping virtual line numbers (not counting discarded lines)
- X to real ones (counting those lines). Both are origin-0. */
- X int *realindexes;
- X
- X /* Total number of nondiscarded lines. */
- X int nondiscarded_lines;
- X
- X /* Vector, indexed by real origin-0 line number,
- X containing 1 for a line that is an insertion or a deletion.
- X The results of comparison are stored here. */
- X char *changed_flag;
- X
- X /* 1 if file ends in a line with no final newline. */
- X int missing_newline;
- X
- X /* 1 more than the maximum equivalence value used for this or its
- X sibling file. */
- X int equiv_max;
- X
- X /* Table translating diff's internal line numbers
- X to actual line numbers in the file.
- X This is needed only when some lines have been discarded.
- X The allocated size is always linbufsize
- X and the number of valid elements is buffered_lines. */
- X int *ltran;
- X};
- X
- X/* Describe the two files currently being compared. */
- X
- Xstruct file_data files[2];
- X
- X/* Queue up one-line messages to be printed at the end,
- X when -l is specified. Each message is recorded with a `struct msg'. */
- X
- Xstruct msg
- X{
- X struct msg *next;
- X char *format;
- X char *arg1;
- X char *arg2;
- X};
- X
- X/* Head of the chain of queues messages. */
- X
- XEXTERN struct msg *msg_chain;
- X
- X/* Tail of the chain of queues messages. */
- X
- XEXTERN struct msg *msg_chain_end;
- X
- X/* Stdio stream to output diffs to. */
- X
- XEXTERN FILE *outfile;
- X
- X/* Declare various functions. */
- X
- X#ifdef __STDC__
- X#define VOID void
- X#else
- X#define VOID char
- X#endif
- XVOID *xmalloc ();
- XVOID *xrealloc ();
- Xchar *concat ();
- Xvoid free ();
- Xchar *rindex ();
- Xchar *index ();
- X
- Xvoid analyze_hunk ();
- Xvoid error ();
- Xvoid fatal ();
- Xvoid message ();
- Xvoid perror_with_name ();
- Xvoid pfatal_with_name ();
- Xvoid print_1_line ();
- Xvoid print_message_queue ();
- Xvoid print_number_range ();
- Xvoid print_script ();
- Xvoid translate_range ();
- END_OF_FILE
- if test 10400 -ne `wc -c <'diff.h'`; then
- echo shar: \"'diff.h'\" unpacked with wrong size!
- fi
- # end of 'diff.h'
- fi
- if test -f 'regex.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'regex.h'\"
- else
- echo shar: Extracting \"'regex.h'\" \(9584 characters\)
- sed "s/^X//" >'regex.h' <<'END_OF_FILE'
- X/* Definitions for data structures callers pass the regex library.
- X
- X Copyright (C) 1985, 1989-90 Free Software Foundation, Inc.
- X
- X This program is free software; you can redistribute it and/or modify
- X it under the terms of the GNU General Public License as published by
- X the Free Software Foundation; either version 1, or (at your option)
- X any later version.
- X
- X This program is distributed in the hope that it will be useful,
- X but WITHOUT ANY WARRANTY; without even the implied warranty of
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X GNU General Public License for more details.
- X
- X You should have received a copy of the GNU General Public License
- X along with this program; if not, write to the Free Software
- X Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
- X
- X
- X#ifdef __GNUC__
- X #pragma once
- X#endif
- X
- X#ifndef __REGEXP_LIBRARY
- X#define __REGEXP_LIBRARY
- X
- X/* Define number of parens for which we record the beginnings and ends.
- X This affects how much space the `struct re_registers' type takes up. */
- X#ifndef RE_NREGS
- X#define RE_NREGS 10
- X#endif
- X
- X#define BYTEWIDTH 8
- X
- X
- X/* Maximum number of duplicates an interval can allow. */
- X#define RE_DUP_MAX ((1 << 15) - 1)
- X
- X
- X/* This defines the various regexp syntaxes. */
- Xextern int obscure_syntax;
- X
- X
- X/* The following bits are used in the obscure_syntax variable to choose among
- X alternative regexp syntaxes. */
- X
- X/* If this bit is set, plain parentheses serve as grouping, and backslash
- X parentheses are needed for literal searching.
- X If not set, backslash-parentheses are grouping, and plain parentheses
- X are for literal searching. */
- X#define RE_NO_BK_PARENS 1
- X
- X/* If this bit is set, plain | serves as the `or'-operator, and \| is a
- X literal.
- X If not set, \| serves as the `or'-operator, and | is a literal. */
- X#define RE_NO_BK_VBAR (1 << 1)
- X
- X/* If this bit is not set, plain + or ? serves as an operator, and \+, \? are
- X literals.
- X If set, \+, \? are operators and plain +, ? are literals. */
- X#define RE_BK_PLUS_QM (1 << 2)
- X
- X/* If this bit is set, | binds tighter than ^ or $.
- X If not set, the contrary. */
- X#define RE_TIGHT_VBAR (1 << 3)
- X
- X/* If this bit is set, then treat newline as an OR operator.
- X If not set, treat it as a normal character. */
- X#define RE_NEWLINE_OR (1 << 4)
- X
- X/* If this bit is set, then special characters may act as normal
- X characters in some contexts. Specifically, this applies to:
- X ^ -- only special at the beginning, or after ( or |;
- X $ -- only special at the end, or before ) or |;
- X *, +, ? -- only special when not after the beginning, (, or |.
- X If this bit is not set, special characters (such as *, ^, and $)
- X always have their special meaning regardless of the surrounding
- X context. */
- X#define RE_CONTEXT_INDEP_OPS (1 << 5)
- X
- X/* If this bit is not set, then \ before anything inside [ and ] is taken as
- X a real \.
- X If set, then such a \ escapes the following character. This is a
- X special case for awk. */
- X#define RE_AWK_CLASS_HACK (1 << 6)
- X
- X/* If this bit is set, then \{ and \} or { and } serve as interval operators.
- X If not set, then \{ and \} and { and } are treated as literals. */
- X#define RE_INTERVALS (1 << 7)
- X
- X/* If this bit is not set, then \{ and \} serve as interval operators and
- X { and } are literals.
- X If set, then { and } serve as interval operators and \{ and \} are
- X literals. */
- X#define RE_NO_BK_CURLY_BRACES (1 << 8)
- X
- X/* If this bit is set, then character classes are supported; they are:
- X [:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:],
- X [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
- X If not set, then character classes are not supported. */
- X#define RE_CHAR_CLASSES (1 << 9)
- X
- X/* If this bit is set, then the dot re doesn't match a null byte.
- X If not set, it does. */
- X#define RE_DOT_NOT_NULL (1 << 10)
- X
- X/* If this bit is set, then [^...] doesn't match a newline.
- X If not set, it does. */
- X#define RE_HAT_NOT_NEWLINE (1 << 11)
- X
- X/* If this bit is set, back references are recognized.
- X If not set, they aren't. */
- X#define RE_NO_BK_REFS (1 << 12)
- X
- X/* If this bit is set, back references must refer to a preceding
- X subexpression. If not set, a back reference to a nonexistent
- X subexpression is treated as literal characters. */
- X#define RE_NO_EMPTY_BK_REF (1 << 13)
- X
- X/* If this bit is set, bracket expressions can't be empty.
- X If it is set, they can be empty. */
- X#define RE_NO_EMPTY_BRACKETS (1 << 14)
- X
- X/* If this bit is set, then *, +, ? and { cannot be first in an re or
- X immediately after a |, or a (. Furthermore, a | cannot be first or
- X last in an re, or immediately follow another | or a (. Also, a ^
- X cannot appear in a nonleading position and a $ cannot appear in a
- X nontrailing position (outside of bracket expressions, that is). */
- X#define RE_CONTEXTUAL_INVALID_OPS (1 << 15)
- X
- X/* If this bit is set, then +, ? and | aren't recognized as operators.
- X If it's not, they are. */
- X#define RE_LIMITED_OPS (1 << 16)
- X
- X/* If this bit is set, then an ending range point has to collate higher
- X or equal to the starting range point.
- X If it's not set, then when the ending range point collates higher
- X than the starting range point, the range is just considered empty. */
- X#define RE_NO_EMPTY_RANGES (1 << 17)
- X
- X/* If this bit is set, then a hyphen (-) can't be an ending range point.
- X If it isn't, then it can. */
- X#define RE_NO_HYPHEN_RANGE_END (1 << 18)
- X
- X
- X/* Define combinations of bits for the standard possibilities. */
- X#define RE_SYNTAX_POSIX_AWK (RE_NO_BK_PARENS | RE_NO_BK_VBAR \
- X | RE_CONTEXT_INDEP_OPS)
- X#define RE_SYNTAX_AWK (RE_NO_BK_PARENS | RE_NO_BK_VBAR \
- X | RE_CONTEXT_INDEP_OPS | RE_AWK_CLASS_HACK)
- X#define RE_SYNTAX_EGREP (RE_NO_BK_PARENS | RE_NO_BK_VBAR \
- X | RE_CONTEXT_INDEP_OPS | RE_NEWLINE_OR)
- X#define RE_SYNTAX_GREP (RE_BK_PLUS_QM | RE_NEWLINE_OR)
- X#define RE_SYNTAX_EMACS 0
- X#define RE_SYNTAX_POSIX_BASIC (RE_INTERVALS | RE_BK_PLUS_QM \
- X | RE_CHAR_CLASSES | RE_DOT_NOT_NULL \
- X | RE_HAT_NOT_NEWLINE | RE_NO_EMPTY_BK_REF \
- X | RE_NO_EMPTY_BRACKETS | RE_LIMITED_OPS \
- X | RE_NO_EMPTY_RANGES | RE_NO_HYPHEN_RANGE_END)
- X
- X#define RE_SYNTAX_POSIX_EXTENDED (RE_INTERVALS | RE_NO_BK_CURLY_BRACES \
- X | RE_NO_BK_VBAR | RE_NO_BK_PARENS \
- X | RE_HAT_NOT_NEWLINE | RE_CHAR_CLASSES \
- X | RE_NO_EMPTY_BRACKETS | RE_CONTEXTUAL_INVALID_OPS \
- X | RE_NO_BK_REFS | RE_NO_EMPTY_RANGES \
- X | RE_NO_HYPHEN_RANGE_END)
- X
- X
- X/* This data structure is used to represent a compiled pattern. */
- X
- Xstruct re_pattern_buffer
- X {
- X char *buffer; /* Space holding the compiled pattern commands. */
- X long allocated; /* Size of space that `buffer' points to. */
- X long used; /* Length of portion of buffer actually occupied */
- X char *fastmap; /* Pointer to fastmap, if any, or zero if none. */
- X /* re_search uses the fastmap, if there is one,
- X to skip over totally implausible characters. */
- X char *translate; /* Translate table to apply to all characters before
- X comparing, or zero for no translation.
- X The translation is applied to a pattern when it is
- X compiled and to data when it is matched. */
- X char fastmap_accurate;
- X /* Set to zero when a new pattern is stored,
- X set to one when the fastmap is updated from it. */
- X char can_be_null; /* Set to one by compiling fastmap
- X if this pattern might match the null string.
- X It does not necessarily match the null string
- X in that case, but if this is zero, it cannot.
- X 2 as value means can match null string
- X but at end of range or before a character
- X listed in the fastmap. */
- X };
- X
- X
- X/* search.c (search_buffer) needs this one value. It is defined both in
- X regex.c and here. */
- X#define RE_EXACTN_VALUE 1
- X
- X
- X/* Structure to store register contents data in.
- X
- X Pass the address of such a structure as an argument to re_match, etc.,
- X if you want this information back.
- X
- X For i from 1 to RE_NREGS - 1, start[i] records the starting index in
- X the string of where the ith subexpression matched, and end[i] records
- X one after the ending index. start[0] and end[0] are analogous, for
- X the entire pattern. */
- X
- Xstruct re_registers
- X {
- X int start[RE_NREGS];
- X int end[RE_NREGS];
- X };
- X
- X
- X
- X#ifdef __STDC__
- X
- Xextern char *re_compile_pattern (char *, int, struct re_pattern_buffer *);
- X/* Is this really advertised? */
- Xextern void re_compile_fastmap (struct re_pattern_buffer *);
- Xextern int re_search (struct re_pattern_buffer *, char*, int, int, int,
- X struct re_registers *);
- Xextern int re_search_2 (struct re_pattern_buffer *, char *, int,
- X char *, int, int, int,
- X struct re_registers *, int);
- Xextern int re_match (struct re_pattern_buffer *, char *, int, int,
- X struct re_registers *);
- Xextern int re_match_2 (struct re_pattern_buffer *, char *, int,
- X char *, int, int, struct re_registers *, int);
- X
- X/* 4.2 bsd compatibility. */
- Xextern char *re_comp (char *);
- Xextern int re_exec (char *);
- X
- X#else /* !__STDC__ */
- X
- Xextern char *re_compile_pattern ();
- X/* Is this really advertised? */
- Xextern void re_compile_fastmap ();
- Xextern int re_search (), re_search_2 ();
- Xextern int re_match (), re_match_2 ();
- X
- X/* 4.2 bsd compatibility. */
- Xextern char *re_comp ();
- Xextern int re_exec ();
- X
- X#endif /* __STDC__ */
- X
- X
- X#ifdef SYNTAX_TABLE
- Xextern char *re_syntax_table;
- X#endif
- X
- X#endif /* !__REGEXP_LIBRARY */
- END_OF_FILE
- if test 9584 -ne `wc -c <'regex.h'`; then
- echo shar: \"'regex.h'\" unpacked with wrong size!
- fi
- # end of 'regex.h'
- fi
- echo shar: End of archive 2 \(of 8\).
- cp /dev/null ark2isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 8 archives.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-
- exit 0 # Just in case...
-